﻿using IdentityServer4.Models;
using System.Collections.Generic;
using IdentityServer4.Test;
using Microsoft.AspNetCore.Identity;
using IdentityServer4;

namespace Cas
{
    public static class Config
    {
        public static List<TestUser> GetUsers()
        {
            return new List<TestUser>
            {
                new TestUser
                {
                    SubjectId = "1",
                    Username = "test1",
                    Password = "1"
                },
                new TestUser
                {
                    SubjectId = "2",
                    Username = "test2",
                    Password = "2"
                }
            };
        }

        public static IEnumerable<IdentityResource> GetIdentityResources()
        {
            return new IdentityResource[]
            {
                //new IdentityResources.OpenId(), //必须要添加，否则报无效的scope错误
                //new IdentityResources.Profile()
            };
        }

        public static IEnumerable<ApiResource> GetApis()
        {
            return new List<ApiResource>
            {
                new ApiResource("feapi", "My API")
            };
        }

        public static IEnumerable<Client> GetClients()
        {
            return new List<Client>
            {
                new Client
                {
                    ClientId ="fe",
                    ClientName = "front-end client",
                    AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
                    ClientSecrets = {new Secret("fesecret".Sha256())},
                    AllowedScopes = {
                        "feapi",
                        //IdentityServerConstants.StandardScopes.OpenId,
                        //IdentityServerConstants.StandardScopes.Profile
                    }
                }
            };
        }
    }
}

